package cc.magicjson.mall.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient
public class GatewayApplication {
	// ... (内容与之前相同，只是包名更改)

	public static void main(String[] args) {
		SpringApplication.run(GatewayApplication.class, args);
	}

	@Bean
	public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
		return builder.routes()
				.route("order_route", r -> r.path("/orders/**")
						.uri("lb://mall-cloud-order"))
				.route("member_route", r -> r.path("/members/**")
						.uri("lb://mall-cloud-member"))
				.route("product_route", r -> r.path("/products/**")
						.uri("lb://mall-cloud-product"))
				.build();
	}
}